package mammuthus.web.action

import org.springframework.web.bind.annotation.RequestMapping
import javax.servlet.http.HttpServletRequest
import java.util
import scala.collection.JavaConversions._

/**
 * 6/18/15 WilliamZhu(allwefantasy@gmail.com)
 */
trait SparkNotebookAction {
  this: AppAction =>

  @RequestMapping(Array("startSparkNotebook.html"))
  def startSparkNotebook(req: HttpServletRequest) = {


    "shellCommandExecuteResult"
  }


  def sparkNotebookConfigure(req: HttpServletRequest, app: String, step: String, slave: Array[String]): Unit = {
    if (app != "spark-notebook") return

    val stepName = if (step.isEmpty) {
      req.setAttribute("step", "finish")
      s"$app 安装节点选取"
    } else {
      val iterKVs = new util.HashMap[String, String]()
      iterKVs.put("slave", slave.mkString(","))
      val hadoops:util.List[String] = slaveService.findAppNamesByApp("hadoop").split(",").toList

      req.setAttribute("hadoops",hadoops)
      req.setAttribute("iterKVs", iterKVs)
    }
    req.setAttribute("stepName", stepName)
    req.setAttribute("configureType",app)
  }


}
